package com.dstz.demo.rest.controller;

import com.dstz.base.api.aop.annotion.CatchErr;
import com.dstz.base.api.query.QueryFilter;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.db.model.page.PageResult;
import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.PcompanyManager;
import com.dstz.demo.core.model.Pcompany;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * 公司基本信息 控制器类<br/>
 * @author  aschs
 * </pre>
 */
@RestController
@RequestMapping("/sys/pcompany")
public class PcompanyController extends BaseController<Pcompany>{
	@Resource
	PcompanyManager pcompanyManager;
	
	
	@Override
	protected String getModelDesc() {
		return "公司基本信息";
	}

	/**
	 * 获取列表
	 * @return
	 */
	@GetMapping("/page/pcompany")
	public PageResult page(HttpServletRequest request, String search,String value){
		QueryFilter queryFilter = getQueryFilter(request);
		if(search!=null){
			queryFilter.addParamsFilter("whereSql",search+" like '%"+value+"%'");
		}

		List<Pcompany> list=pcompanyManager.listPagePcompany(queryFilter);
		return new PageResult(list);
	}

	@PostMapping("/insert")
	@CatchErr("添加失败")
	public ResultMsg insertPcompany(@RequestBody Pcompany pcompany) {
		pcompanyManager.insertPcompany(pcompany);
		return getSuccessResult("添加成功");
	}

}
